package com.xunk.scene.threadpool;

import cn.hutool.core.thread.NamedThreadFactory;

import java.util.concurrent.*;

/**
 * @ProjectName: HIM
 * @Package: com.xunk.scene.threadpool
 * @ClassName: ThreadPoolFactory
 * @Author: luanzhiwei
 * @Description: 线程池
 * @Date: 2021/5/18 15:09
 * @Version: 1.0
 */
public class ThreadPools {

    private ThreadPools() {
        //私有无参构造
    }

    public static ThreadPoolExecutor executor;

    static {
        // 设置核心线程数
        int corePoolSize = 100;
        // 设置最大线程数
        int maximumPoolSize = 100;
        // 设置线程活跃时间
        long keepAliveTime = 60;
        // 设置线程活跃时间单位
        TimeUnit unit = TimeUnit.SECONDS;
        //阻塞队列
        BlockingQueue<Runnable> workQueue = new LinkedBlockingDeque<Runnable>(1000);
        //拒绝策略
        RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy();


        executor = new ThreadPoolExecutor(corePoolSize,
                maximumPoolSize, keepAliveTime, unit, workQueue, handler);
    }


}
